// callback: cmd_show

void cmd_show(istringstream& ss) {
  string what;
  
  if(ss>>what) {
    
    if(what=="domain") {
      if(fd.empty()) throw "fd domain empty";
      for(int i=0;i<(int)fd.size();i++) {
        int nx,ny,nz;
        fd[i]->solver->GetDim(nx,ny,nz);
        string msg("name=");
        msg.append(fd[i]->name+" dim=("+
                   as_string(nx)+","+
                   as_string(ny)+","+
                   as_string(nz)+") ");
        
        if(current==i) msg.append("*");
        
        say(msg);
      }
    }
    
    if(what=="current") {
      if(fd.empty()) throw "fd domain empty";
      say("current domain: "+fd[current]->name);
    }
    
    else if(what=="buffer") {
      if(buffer.empty()) throw "buffer empty";
      for(int i=0;i<(int)buffer.size();i++) 
        
        say(buffer[i]->name+" dim=("+
            as_string(buffer[i]->nx)+","+
            as_string(buffer[i]->ny)+","+
            as_string(buffer[i]->nz)+")");
      
    }
    
    else if(what=="table") {
      if(table.empty()) throw "table empty";
      for(int i=0;i<(int)table.size();i++) 
        say(table[i]->name);
    }
    
    else if(what=="plotter") {
      if(plotter.empty()) throw "plotter empty";
      for(int i=0;i<(int)plotter.size();i++) 
        say(plotter[i]->name+" data= "+
            plotter[i]->plotdata.name+" slab= "+
            as_string(plotter[i]->slab));
    }
    
    else if(what=="source") {
      if(fd.empty()) throw "domain empty";
      say(fd[current]->src);
    }
    
    else if(what=="con") {
      if(fd.empty()) throw "domain empty";
      say(fd[current]->con);
    }
    
    else if(what=="cap") {
      if(fd.empty()) throw "domain empty";
      say(fd[current]->cap);
    }
    
  } else {
    if(fd.size()) {
      say("# domain");
      istringstream css("domain");
      cmd_show(css);
    }
    if(plotter.size()) {
      say("# plotter");
      istringstream css("plotter");
      cmd_show(css);
    }
    if(buffer.size()) {
      say("# buffer");
      istringstream css("buffer");
      cmd_show(css);
    }
  }
}
